package birdsong.client;

import java.io.IOException;
import java.net.UnknownHostException;

import javax.swing.JOptionPane;

import birdsong.comm.ClientCommImp;

public class BirdsongClientImp implements BirdsongClient {
	
	public BirdsongClientImp() {
		
	}

	public void start(ClientCommImp clientComm) {
		
		try {
			String nickname = JOptionPane.showInputDialog("Nickame?");
			
			clientComm.connect("localhost", nickname );

			while (clientComm.isConnected()) {
				String message = JOptionPane.showInputDialog("Write your message!");
				
				if (message.equals("FIM")) {
					clientComm.disconnect();
				}
				clientComm.sendBirdsongMessage(message);
			}
			
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	public static void main(String[] args) {
		BirdsongClientImp client = new BirdsongClientImp();
		ClientCommImp clientComm = new ClientCommImp();
		client.start(clientComm);
	}
	
}
